<template>
	<view class="index">
		<item v-for="(item,index) in data" :key="index" :data="item" :index="index" :link="`/pages/detail/detail`"
			@postComment="comment" @share="share" @praise="praise" @del="del" userId="1" :delShow="false"></item>
	</view>
</template>

<script>
	import json from "@/static/infos.js"
	import item from "@/components/Circle/Circle.vue"
	export default {
		components: {
			item
		},
		data() {
			return {
				data: {},
				scrollTop: 0,
			}
		},
		onReady() {
			uni.createIntersectionObserver().relativeToViewport({
				bottom: 1000
			}).observe('#video_' + item.id, (res) => {
				console.log(res)
				// if (res.boundingClientRect.top > 0) {
				// 	let current = index;
				// 	if (res.intersectionRatio == 0) {
				// 		current = current - 1
				// 	}
				// }
			})
			json.map(e => {
				// var c = e.content.split(/(1\d{10})/),
				// 	list = []
				// for (var i in c) {
				// 	var flag = c[i] != '' && /^(1\d{10})$/.test(c[i])
				// 	c[i] != '' && list.push({
				// 		type: flag ? 'phone' : 'text',
				// 		val: c[i]
				// 	})
				// }
				// e.content = list
				e.comments.map(c => {
					c.menuShow = false
				})
			})
			this.data = json
		},
		onPageScroll(e) {
			// this.scrollTop = e.scrollTop
			this.data.forEach((item, index) => {
				if (item.category == "video") {}
			})

		},
		methods: {
			//评论菜单的显示（:如果需要必须
			show(i, j) {
				this.data[i].comments[j].menuShow = true
			},
			//关闭评论菜单（:如果需要必须
			close(index) {
				this.data[index].comments.map(e => {
					e.menuShow = false
				})
			},
			//评论
			comment(e) {
				this.data[e.index].comments.push({
					"id": e.id,
					"releaseInfoId": e.releaseInfoId,
					"fromUserId": 1,
					"toUserId": e.toUserId,
					"content": e.text,
					"created": ""
				})
				uni.showToast({
					title: 'success',
					duration: 2000
				});
			},
			//分享
			share(id) {
				uni.showToast({
					title: 'success',
					duration: 2000
				});
			},
			//点赞
			praise(id) {
				uni.showToast({
					title: 'success',
					duration: 2000
				});
			},
			del(id) {
				console.log('del')
			}
		},
		onPullDownRefresh() {

		}
	}
</script>

<style>
</style>
